﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.Search.TxMainSearchControl.TxSearchModelUtils
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using Tecnomatix.Engineering.Ui.WPF;


namespace DnProcessSimulateCommands.Search.TxMainSearchControl;

internal static class TxSearchModelUtils
{
  internal static string COMMAND_SEARCH_STATUS = "CommandSearchIsActive";
  internal static string OBJECTS_SEARCH_STATUS = "ObjectsSearchIsActive";

  internal static string CleanStringForSearch(string str) => str.ToLower();

  internal static bool WasHandled(object obj) => obj is TxSearchItemITxObject;

  internal static void StoreToReg(
    TxWindow win,
    bool commandSearchIsActive,
    bool objectsSearchIsActive)
  {
    TxWindowSettings.StoreWindowValue(win, TxSearchModelUtils.COMMAND_SEARCH_STATUS, (object) commandSearchIsActive);
    TxWindowSettings.StoreWindowValue(win, TxSearchModelUtils.OBJECTS_SEARCH_STATUS, (object) objectsSearchIsActive);
  }

  internal static void LoadFromReg(
    TxWindow win,
    out bool commandSearchIsActive,
    out bool objectsSearchIsActive)
  {
    commandSearchIsActive = true;
    objectsSearchIsActive = true;
    object obj1 = (object) null;
    object obj2 = (object) null;
    TxWindowSettings.RestoreWindowValue(win, TxSearchModelUtils.COMMAND_SEARCH_STATUS, ref obj1);
    TxWindowSettings.RestoreWindowValue(win, TxSearchModelUtils.OBJECTS_SEARCH_STATUS, ref obj2);
    if (obj1 != null)
      bool.TryParse(obj1 as string, out commandSearchIsActive);
    if (obj2 == null)
      return;
    bool.TryParse(obj2 as string, out objectsSearchIsActive);
  }
}
